package game.base;

import android.graphics.Canvas;
import android.view.MotionEvent;

public abstract class BaseFrame {
	private float x, y, width, height;
	private BaseCanvas father;
	public BaseFrame(BaseCanvas father, float _x, float _y, float _width, float _height) {
		x = _x;
		y = _y;
		width = _width;
		height = _height;
		this.father = father;
	}
	
	public float getX() {
		return x;
	}
	
	public float getY() {
		return y;
	}
	
	public float getWidth() {
		return width;
	}
	
	public float getHeight() {
		return height;
	}
	
	public void close() {
		if (father != null) {
			father.closeFrame(this);
		}
	}
	
	public BaseCanvas getFather() {
		return father;
	}

	public abstract void onDraw(Canvas canvas);
	
	public abstract void onUpdate(long difftime);
	
	public abstract boolean onTouchEvent(MotionEvent event);
	
	public boolean collided(float _x, float _y) {
		return _x > x && _y > y && _x < x + width && _y < y + height;
	}

}
